package com.androidvizlab.bachelor.Interface;

/**
 * Used as the base class for socket clients. This is mainly used to pass on the data received by the client 
 * to it's observers. A way to abstract communication between objects.
 * 
 * @author TheHive
 */
public class SimpleSocketClient{
	
	private SocketClientSimpleCallback callbackhandler;
	
	public SimpleSocketClient()
	{
		
	}

	public void registerCallbackHandler(SocketClientSimpleCallback handler) 
	{
		this.callbackhandler = handler;
	}

	public void removeCallbackHandler(SocketClientSimpleCallback handler) 
	{
		if(handler != null && handler.equals(callbackhandler))
		{
			this.callbackhandler = null;
		}
	}

	public synchronized void notifyCallbackHandler(Object object) 
	{
		callbackhandler.onDataReceived(object);
	}	
}